class Scenario
  attr_reader :terms

  def initialize
    @terms = []
    @vocabulary = Vocabulary.all_terms
  end
  
  def add_term term
    raise "#{term} is not contained in the vocabulary: #{@vocabulary}" unless @vocabulary.include? term

    @terms << term

    self
  end

  def next_terms
    return @vocabulary if @terms.empty?

    Association.find_all_by_parent_id(last_term_id).collect {|association| association.child.term}
  end

  private
  def last_term_id
    Vocabulary.find_by_term(@terms[-1]).id  
  end
end